
$('#head_tabs').on('click', '.tab', function () {
    $(this).addClass('tab_active').siblings('span').removeClass('tab_active')
    console.log($(this).index());
    if( $(this).index()==0){
        $('.user_info').show();
        $('.user_safe').hide();
    }else{
        $('.user_safe').show();
        $('.user_info').hide();
    }
});
$('.address_add').on('click',function(){
    $('.dialog').css('display','flex')
})

$('.dialog').on('click','.mask',function(){
    $('.dialog').hide()
})
$('.dialog').on('click','.sure',function(){
    $('.dialog').hide()
})
$('.dialog').on('click','.cancel',function(){
    $('.dialog').hide()
})
$('.address_list').on('click','.edit',function(){
    $('.dialog').css('display','flex')
})

$('.address_list').on('click','.del',function(){
    let index= $(this).parents('.address_item').index()
    $('.address_list .address_item').eq(index).remove()
})


$('#fileSelector,#album').on('change', function (event) {// 鏇存敼鐢ㄦ埛澶村儚
   
    if (event.target.files[0] != undefined) {
        if (event.target.files[0]['type'] == 'image/jpg' || event.target.files[0]['type'] == 'image/png' || event.target.files[0]['type'] == 'image/jpeg' || event.target.files[0]['type'] == 'image/gif' || event.target.files[0]['type'] == 'image/webp') {
            if (event.target.files[0]['tysizepe'] > 1024 * 1024 * 1) {
                newsAlert('图片尺寸不能大于1MB', 2)
            } else {
                // handleFileInUploading(event.target.files[0])
                var reader = new FileReader()
                reader.onload = function (e) {
                    $('.user_change_headimg').attr('src', e.target.result)
                }
                reader.readAsDataURL(event.target.files[0])
            }

        } else {
            newsAlert('上传头像格式不正确', 2)
        }
    }



})